/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tags.customs;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

/**
 *
 * @author CUCAINHO
 */
public class TemplateTag extends TagSupport {

    private String title;
    private String login;
    private String header;
    private String slideshow;
    private String menulamp;
    private String left;
    private String mainContent;
    private String footer;

    public void setFooter(String footer) {
        this.footer = footer;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public void setHeader(String header) {
        this.header = header;
    }

    public void setSlideshow(String slideshow) {
        this.slideshow = slideshow;
    }

    public void setMenulamp(String menulamp) {
        this.menulamp = menulamp;
    }

    public void setLeft(String left) {
        this.left = left;
    }

    public void setMainContent(String mainContent) {
        this.mainContent = mainContent;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Override
    public int doStartTag() {
        JspWriter out = this.pageContext.getOut();
        try {

            out.println("<!DOCTYPE html>");
            out.println("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>");
            out.print("<html>");
            out.print("   <head>");
            out.print("      <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>");
            out.print("      <title>" + title + "</title>");

            out.println("<link rel='stylesheet' type='text/css' href='css/style_deal_list.css'/>");
            out.println("<link rel='stylesheet' type='text/css' href='css/style_deal.css'/>");
            out.println("<link rel='stylesheet' type='text/css' href='css/style.css'/>");
            out.println("<link rel='stylesheet' type='text/css' href='css/lavalamp_test.css'/>");
            out.println("<link rel='stylesheet' type='text/css' href='css/detail_deal.css'/>");
            out.println("<!-- phan menu -->");
            out.println("	<link rel='stylesheet' type='text/css' href='css/lavalamp_test.css'/>");
            out.println("   ");
            out.println(" 	 <script type='text/javascript' src='js/jquery-1.4.2.min.js'></script>");
            out.println("     <script type='text/javascript' src='js/mejs.js'></script>");
            out.println("    <script type='text/javascript' src='js/jquery.easing.min.js'></script>");
            out.println("    <script type='text/javascript' src='js/jquery.easing.min.js'></script>");
            out.println("    <script type='text/javascript' src='js/jquery.lavalamp.min.js'></script>      ");
            out.println("     <!-- phần slides hình-->");
            out.println("  ");
            out.println("  	<link rel='stylesheet' type='text/css' href='css/css_slideshow/style_show.css'/>");
            out.println(" ");
            out.println(" 	<!-- <script type='text/javascript' src='js_slideshow/jquery.min.js'></script>  -->");
            out.println(" ");
            out.println("  	<script type='text/javascript' src='js/js_slideshow/js1.js'></script> ");
            out.println("   <!-- login -->");
            out.println("   	");
            out.println("    <script type='text/javascript'>");
            out.println("	$(function(){");
            out.println("	   // $('body').append('<div id='button_login'></div><div id='den_mo'></div>');//chèn 2 thẻ DIV vào HTML");
            out.println("		//window.alert('abc');");
            out.println("		$('.button_login').click(function(){");
            out.println("			var $leftLogin=$('#den_mo').width();//lấy chiều rộng thẻ #den_mo");
            out.println("			var $topLogin=$('#den_mo').height();//lấy chiều cao thẻ #den_mo");
            out.println("			var $heightLogin=$('#login').height();//lấy chiều cao thẻ #login");
            out.println("			$('#login').css({'left':($leftLogin-300)/2,'top':($topLogin-$heightLogin-20)/2});//canh ra giữa trang     web+thêm 10px len trên");
            out.println("			$('#den_mo,#login').fadeIn();//cho hiện đèn và khung LOGIN");
            out.println("		});");
            out.println("		$('#content_login h4').click(function(){");
            out.println("			$('#den_mo,#login').hide();//ĐÓNG đèn mờ và khung LOGIN");
            out.println("		});");
            out.println("	});");
            out.println("</script>");
            out.println("");
            out.println("   ");
            out.println("   <!--end login-->");


            out.println("  ");
            out.println("   ");
            out.println("");
            out.println("  ");
            out.println("  <!--end phần slideshow hình-->");
            out.println("<link rel='stylesheet' type='text/css' href='css/login.css'/>");
            out.println("  ");
            out.println("  ");
            out.println("	");
            out.println("	<script type='text/javascript'>");
            out.println("	");
            out.println("	");
            out.println("    $(function() {");
            out.println("            $('#1, #2, #3').lavaLamp({");
            out.println("               	fx: 'backout',");
            out.println("                speed: 700,");
            out.println("                click: function(event, menuItem) {");
            out.println("                    return true;");
            out.println("                }");
            out.println("            });");
            out.println("			");
            out.println("			");
            out.println("        });");
            out.println("		");
            out.println("		<!-- phan search -->");
            out.println("		");
            out.println("		$(document).ready(function()");
            out.println("							   ");
            out.println("		{");
            out.println("			/*$('#main > div').addClass('highlight');");
            out.println("			$('#main div:not(#search)').('background');*/");
            out.println("");
            out.println("			var $ts = $('.txt_search');");
            out.println("			$('.txt_search').click(function(event)");
            out.println("				{");
            out.println("					$ts.attr({'value': ''});					");
            out.println("					");
            out.println("					/*$ts.css('background','#FFF');*/");
            out.println("					var s_width = $ts.width();");
            out.println("					//window.alert(s_width);");
            out.println("					");
            out.println("					if(s_width == 123)");
            out.println("					{");
            out.println("						$ts.animate({width:'+=50px'},'slow');");
            out.println("						$('.s_left').animate({'margin-left':'-=50px'},'slow');");
            out.println("						$('.cboLoai').animate({'margin-left':'-=50px'},'slow');");
            out.println("						");
            out.println("						");
            out.println("    			");
            out.println("						");
            out.println("					}");
            out.println("					event.stopPropagation();");
            out.println("				}");
            out.println("				);	");
            out.println("			//$('.all:not(search)').click(function()");
            out.println("					//$('div:not(.search)').click(function()");
            out.println("					//$('#main > div').addClass('highlight');");
            out.println("					$('div:not(.searchs)').click(function(event)");
            out.println("					{");
            out.println("						var s_width_s = $('.txt_search').width();	");
            out.println("						if(s_width_s > 123)");
            out.println("						{");
            out.println("							//window.alert(s_width_s);");
            out.println("							$('.txt_search').animate({width:'-=50px'},'slow');");
            out.println("							$ts.attr({'value': 'Search'});");
            out.println("							$('.s_left').animate({'margin-left':'+=50px'},'slow');");
            out.println("							$('.cboLoai').animate({'margin-left':'+=50px'},'slow');");
            out.println("							//$('.s_left').animate({margin:'10px 10px 10px +=5px'},'slow');");
            out.println("							/*$ts.css('background','#FFF');*/");
            out.println("					");
            out.println("							//event.stopPropagation();");
            out.println("						}");
            out.println("						event.stopPropagation();");
            out.println("					}");
            out.println("					);");
            out.println("			");
            out.println("		}");
            out.println("		");
            out.println("		);");
            out.println("		<!--  end phan search -->");
            out.println("		");
            out.println("		");
            out.println("    </script>");
            out.println("  ");
            out.println("    ");
            out.println("<!-- end phan menu -->");
            out.println("");
            out.println("</head>");
            out.println("");
            out.println("<body>");
            this.pageContext.include(login);
            out.println("<div class='body'>");
            out.println("	");
            out.println("    ");
            this.pageContext.include(header);
            out.println("    ");
            out.println("          ");
            this.pageContext.include(menulamp);
            out.println("    ");
            out.println("    ");
            out.println("<div id='main_body'>");
            out.println("    <div id='main'>");
            out.println("	");
            out.println("	<!-- TemplateBeginEditable name='slideshow_top' -->");
            this.pageContext.include(slideshow);
            out.println("	<!-- TemplateEndEditable -->");
            out.println("	");
            this.pageContext.include(left);
            out.println("            ");
            out.println("            ");
            out.println("	<div id='main_right'>");
            out.println("	<!-- TemplateBeginEditable name='Main_Content' -->    ");
            this.pageContext.include(mainContent);
            out.println("	<!-- TemplateEndEditable --> ");
            out.println("    ");
            out.println("      </div> <!---End div main right->");
            out.println("    </div><!--end div main-->");
            out.println("    	");
            out.println("        ");
            out.println("        <div id='vide'></div>");
            out.println("        ");
            out.println("   ");
            out.println("        ");
            out.println("  </div><!--end div main body-->");
            out.println("    ");
            this.pageContext.include(footer);
            out.println("");
            out.println("</div> <!-- End div body-->");
            out.println("</body>");
            out.println("</html>");
            out.println("");
            out.println("");

        } catch (IOException ex) {
            Logger.getLogger(TemplateTag.class.getName())
                    .log(Level.SEVERE, null, ex);
        } catch (ServletException ex) {
            Logger.getLogger(TemplateTag.class.getName())
                    .log(Level.SEVERE, null, ex);

        }
        return SKIP_BODY;
    }

    @Override
    public int doEndTag() {
        return EVAL_PAGE;
    }

    @Override
    public void release() {
        this.title = null;
        this.login = null;
        this.header = null;
        this.slideshow = null;
        this.menulamp = null;
        this.left = null;
        this.mainContent = null;
        this.footer = null;
    }
}
